#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'libb@anchent.com'

# 比共享内存灵活,但缓慢
# 支持list,dict,Namespace,Lock,Semaphore,BoundedSemaphore,Condition,Event,Queue,Ｖalue,Array

import os
import time
from multiprocessing import Process, Manager


def download_task(dm, name):
    # print("download_task current pid:%d" % os.getpid())
    dm[name] = name * name
    # print("download_task dm:%s, name:%d" % (dm, name))


if __name__ == '__main__':
    manager = Manager()
    d = manager.dict()
    process_list = []
    for i in range(10):
        p = Process(target=download_task, args=(d, i))
        p.start()
        process_list.append(p)

    for j in process_list:
        j.join()
        print("download_task d:{}".format(d))
